this._source.app.open_new_window(-1);
this.emit('activate-window', null);
}));
+ this._appendSeparator();
+ let appInfo = this._source.app.get_app_info();
+ let actions = appInfo.list_actions();
+ for (let i = 0; i < actions.length; i++) {
+ let action = actions[i];
+ let item = this._appendMenuItem(appInfo.get_action_name(action));
+ item.connect('activate', Lang.bind(this, function(emitter, event) {
+ this._source.app.launch_action(action, event.get_time(), -1);
+ this.emit('activate-window', null);
+ }));
+ }
this._appendSeparator();
let isFavorite = AppFavorites.getAppFavorites().isFavorite(this._source.app.get_id());
}
#endif
+static GAppLaunchContext *
+make_launch_context (guint timestamp,
+ int workspace)
+{
+ GdkAppLaunchContext *context;
+ ShellGlobal *global;
+ MetaScreen *screen;
+ GdkDisplay *gdisplay;
+
+ global = shell_global_get ();
+ screen = shell_global_get_screen (global);
+ gdisplay = gdk_screen_get_display (shell_global_get_gdk_screen (global));
+
+ if (timestamp == 0)
+ timestamp = shell_global_get_current_time (global);
+
+ if (workspace < 0)
+ workspace = meta_screen_get_active_workspace_index (screen);
+
+ context = gdk_display_get_app_launch_context (gdisplay);
+ gdk_app_launch_context_set_timestamp (context, timestamp);
+ gdk_app_launch_context_set_desktop (context, workspace);
+
+ return G_APP_LAUNCH_CONTEXT (context);
+}
+
/**
* shell_app_launch:
* @timestamp: Event timestamp, or 0 for current event timestamp
int workspace,
GError **error)
{
- GdkAppLaunchContext *context;
+ GAppLaunchContext *context;
gboolean ret;
- ShellGlobal *global;
- MetaScreen *screen;
- GdkDisplay *gdisplay;
if (app->info == NULL)
{
return TRUE;
}
- global = shell_global_get ();
- screen = shell_global_get_screen (global);
- gdisplay = gdk_screen_get_display (shell_global_get_gdk_screen (global));
-
- if (timestamp == 0)
- timestamp = shell_global_get_current_time (global);
-
- if (workspace < 0)
- workspace = meta_screen_get_active_workspace_index (screen);
-
- context = gdk_display_get_app_launch_context (gdisplay);
- gdk_app_launch_context_set_timestamp (context, timestamp);
- gdk_app_launch_context_set_desktop (context, workspace);
+ context = make_launch_context (timestamp, workspace),
ret = g_desktop_app_info_launch_uris_as_manager (app->info, NULL,
- G_APP_LAUNCH_CONTEXT (context),
+ context,
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
#ifdef HAVE_SYSTEMD
app_child_setup, (gpointer)shell_app_get_id (app),
return ret;
}
+/**
+ * shell_app_launch_action:
+ * @app: the #ShellApp
+ * @action_name: the name of the action to launch (as obtained by
+ * g_desktop_app_info_list_actions())
+ * @timestamp: Event timestamp, or 0 for current event timestamp
+ * @workspace: Start on this workspace, or -1 for default
+ */
+void
+shell_app_launch_action (ShellApp *app,
+ const char *action_name,
+ guint timestamp,
+ int workspace)
+{
+ GAppLaunchContext *context;
+
+ context = make_launch_context (timestamp, workspace);
+
+ g_desktop_app_info_launch_action (G_DESKTOP_APP_INFO (app->info),
+ action_name, context);
+
+ g_object_unref (context);
+}
+
/**
* shell_app_get_app_info:
* @app: a #ShellApp